package cn.wolfcode.crm.query.impl;

import cn.wolfcode.crm.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

@Setter@Getter
public class SaleChartQueryObject extends QueryObject {
    //根据机构查询
    private Long organId = -1l;
    //根据产品查询
    private Long productId = -1l;
    //保单时间(即单据历史记录中的开始日期)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date minDate;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date maxDate;

    //页面传入的类型,传入的都是e.name/s.name 等这样的字符串,所以使用string接收
    private String groupType ="oz.name";//设置默认为销售人员的类型

    public static Map<String,String> typeMap = new LinkedHashMap<>();
    static{
        typeMap.put("e.username","销售人员");
        typeMap.put("oz.name","保险机构");
        typeMap.put("p.name","保险产品");
        typeMap.put("DATE_FORMAT(ii.applicationDate,'%Y-%m')","保单日期(月)");
        typeMap.put("DATE_FORMAT(ii.applicationDate,'%Y-%m-%d')","保单日期(日)");
    }

    public String getKeyword(){
        return empty(groupType);
    }
}
